summaryrefslogtreecommitdiff
path: root/app/[lng]/evcp/(evcp)/(system)/menu-list/page.tsx
blob: 5a1f71a517c7af55e0640cb134689e072053829d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
// app/evcp/menu-list/page.tsx

import { Suspense } from "react";
import { Card, CardContent, CardDescription, CardHeader, CardTitle } from "@/components/ui/card";
import { Button } from "@/components/ui/button";
import { RefreshCw, Settings } from "lucide-react";
import { getActiveUsers, getMenuAssignments } from "@/lib/menu-list/servcie";
import { InitializeButton } from "@/lib/menu-list/table/initialize-button";
import { MenuListTable } from "@/lib/menu-list/table/menu-list-table";
import { Shell } from "@/components/shell"
import * as React from "react"
import { InformationButton } from "@/components/information/information-button";
import { useTranslation } from "@/i18n";
interface MenuListPageProps {
  params: Promise<{ lng: string }>
}

export default async function MenuListPage({ params }: MenuListPageProps) {
  const { lng } = await params
  const { t } = await useTranslation(lng, 'menu')
  
  // 초기 데이터 로드
  const [menusResult, usersResult] = await Promise.all([
    getMenuAssignments(),
    getActiveUsers()
  ]);

  // 서버사이드에서 번역된 메뉴 데이터 생성
  const translatedMenus = menusResult.data?.map(menu => ({
    ...menu,
    sectionTitle: menu.sectionTitle || "",
    translatedMenuTitle: t(menu.menuTitle || ""),
    translatedSectionTitle: t(menu.sectionTitle || ""),
    translatedMenuGroup: menu.menuGroup ? t(menu.menuGroup) : null,
    translatedMenuDescription: menu.menuDescription ? t(menu.menuDescription) : null
  })) || [];

  return (
    <Shell className="gap-2">
      <div className="flex items-center justify-between space-y-2">
        <div className="flex items-center justify-between space-y-2">
          <div>
            <div className="flex items-center gap-2">
              <h2 className="text-2xl font-bold tracking-tight">
                메뉴 관리
              </h2>
              <InformationButton pagePath="evcp/menu-list" />
            </div>
            {/* <p className="text-muted-foreground">
              각 메뉴별로 담당자를 지정하고 관리할 수 있습니다.
            </p> */}
          </div>
        </div>

      </div>


      <React.Suspense
        fallback={
         ""
        }
      >
        <Card>
          <CardHeader>
            <CardTitle className="flex items-center gap-2">
              <Settings className="h-5 w-5" />
              메뉴 리스트
            </CardTitle>
            <CardDescription>
              시스템의 모든 메뉴와 담당자 정보를 확인할 수 있습니다.
              {menusResult.data?.length > 0 && (
                <span className="ml-2 text-sm">
                  총 {menusResult.data.length}개의 메뉴
                </span>
              )}
            </CardDescription>
          </CardHeader>
          <CardContent>
            <Suspense fallback={<div className="text-center py-8">로딩 중...</div>}>
              <MenuListTable
                initialMenus={translatedMenus}
                initialUsers={usersResult.data || []}
              />
            </Suspense>
          </CardContent>
        </Card>
      </React.Suspense>
    </Shell>

  );
}